package file;

import java.io.File;
import java.io.IOException;

public class FileTest {
    public static void main(String[] args) throws IOException {

        // mkdirs创建多级文件夹
        File file1 = new File("D:\\itheima\\aaa");
        boolean mkdirs = file1.mkdirs();
        System.out.println(mkdirs);

        // createNewFile创建文件
        File file2 = new File("D:\\itheima\\aaa\\a.txt");
        boolean newFile = file2.createNewFile();
        System.out.println(newFile);

        // isFile判断file是否为文件
        File file3 = new File("D:\\itheima\\aaa\\a.txt");
        boolean ruselt = file3.isFile();
        System.out.println(ruselt);

        // isDirectory判断file是否为文件夹
        File file4 = new File("D:\\itheima\\aaa");
        boolean directory = file4.isDirectory();
        System.out.println(directory);

        // exists判断文件或者文件夹是否存在
        File file5 = new File("D:\\itheima\\aaa");
        boolean exists = file5.exists();
        System.out.println(exists);

        // getName获取文件或者文件夹的名字
        File file6 = new File("D:\\itheima\\aaa\\a.txt");
        String name = file6.getName();
        System.out.println(name);

        // delete删除文件或者文件夹
        File file7 = new File("D:\\itheima\\a.txt");
        boolean delete = file7.delete();
        System.out.println(delete);

        //
        File file8 = new File("D:\\itheima\\aaa");
        boolean delete1 = file8.delete();
        System.out.println(delete1);
    }
}
